package com.java2nb.novel.utils;

/**
 * 订单状态枚举（支付/退款）
 */
public enum OrderStatusEnum {
    PAY_PENDING(0, "待支付"),
    PAY_SUCCESS(1, "支付成功"),
    PAY_FAILED(2, "支付失败"),
    PAY_CLOSED(3, "支付关闭"),
    REFUND_PENDING(0, "退款中"),
    REFUND_SUCCESS(1, "退款成功"),
    REFUND_FAILED(2, "退款失败");

    private final Integer code;
    private final String desc;

    OrderStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // getter
    public Integer getCode() { return code; }
    public String getDesc() { return desc; }

    // 校验支付订单状态是否可关闭
    public boolean isCloseable() {
        return this == PAY_PENDING;
    }

    // 校验支付订单状态是否可退款
    public boolean isRefundable() {
        return this == PAY_SUCCESS;
    }
}
